<script>
import Base from "./Base";
export default {
  name: "ChartWordCloud",
  mixins: [Base],
  data() {
    return {
      defaultOption: {
        tooltip: {
          show: true,
        },
        series: [
          {
            type: "wordCloud",
            size: ["9%", "99%"],
            sizeRange: [10, 48], //最小文字——最大文字
            textRotation: [0, 45, 90, -45],
            rotationRange: [-45, 90], //旋转角度区间
            rotationStep: 90, //旋转角度间隔
            shape: "diamond",
            gridSize: 10, //字符间距
            textPadding: 0,
            drawOutOfBound: false,
            autoSize: {
              enable: true,
              minSize: 6,
            },
            textStyle: {
              color: function () {
                return (
                  "rgb(" +
                  [
                    Math.round(Math.random() * 105) + 60,
                    Math.round(Math.random() * 105) + 60,
                    Math.round(Math.random() * 105) + 60,
                  ].join(",") +
                  ")"
                );
              },
              emphasis: {
                shadowBlur: 10,
                shadowColor: "#333",
              },
            },
            data: [],
          },
        ],
      },
    };
  },
  computed: {
    option: function () {
      let series = [];
      const { simpleData } = this.handleData(this.dataset);
      this.defaultOption.series[0].data = simpleData;
      return {
        ...this.defaultOption,
        ...this.dataset.option,
        ...series,
      };
    },
  },
};
</script>
